package com.project.m.api.busi.db.service.hicatcard.distributor;

import com.project.m.api.busi.db.entity.hicatcard.distributor.TDistributor;
import com.project.m.api.busi.db.repo.distributor.DistributorRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class DistributorService {

    @Autowired
    DistributorRepo distributorRepo;

    @Transactional(readOnly = true)
    public List<TDistributor> findByDistributorNumberAndEnable(String distributorNumber, Boolean enable) {
        return distributorRepo.findByDistributorNumberAndEnable(distributorNumber, enable);
    }

    @Transactional(readOnly = true)
    public TDistributor findByDistributorId(Long distributorId) {
        return distributorRepo.findByDistributorId(distributorId);
    }

    public void saveDistributor(TDistributor distributor) {
        distributorRepo.save(distributor);
    }
}
